home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NOVA - For the NeXT Workstation
/
NOVA - For the NeXT Workstation.iso
/
Apps
/
Graphics
/
Viewers
/
FastTIFF
/
TIFFView.m
< prev
next >
Wrap
Text File
|
1992-12-25
|
2KB
|
61 lines
#import <sys/param.h>
#import <strings.h>
#import <appkit/View.h>
#import <appkit/Button.h>
#import <appkit/OpenPanel.h>
#import <appkit/NXImage.h>
#import <appkit/NXBitmapImageRep.h>
#import "TIFFView.h"
@implementation TIFFView
- drawSelf:(NXRect *)rects :(int)count
{
static NXPoint point = {0.0,0.0};
if(isCached)
[image composite:NX_COPY toPoint:&point];
else
[image draw];
return self;
}
- openTIFF:sender
{
char file[MAXPATHLEN];
const char *const *files;
static const char *const imageType[4] = {"tiff"};
id openpanel = [[OpenPanel new] allowMultipleFiles:NO];
if([openpanel runModalForTypes:imageType])
if((files = [openpanel filenames]) && *files){
(void)strcat(strcat(strcpy(file,[openpanel directory]),"/"),*files);
if(image)
[image free];
if(bitmap = image = [[NXBitmapImageRep alloc] initFromFile:file]){
[self sizeTo:[image pixelsWide]:[image pixelsHigh]];
if(isCached)
[[(image = [[NXImage alloc] init]) setDataRetained:YES] useRepresentation:bitmap];
[[[self display] window] makeKeyAndOrderFront:self];
}
else
NXRunAlertPanel("Open Image","Error loading image!","Cancel",NULL,NULL);
}
return self;
}
- toggleCachingMode:sender
{
if(isCached = !isCached)
[[(image = [[NXImage alloc] init]) setDataRetained:YES] useRepresentation:bitmap];
else
image = bitmap;
return self;
}
@end